<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微积分可视化学习平台</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.tailwindcss.com" rel="stylesheet">
    <link rel="stylesheet" href="css/style.css">
</head>
<body class="bg-gray-50">
    <div class="min-h-screen">
        <!-- 顶部导航 -->
        <header class="bg-white shadow-sm border-b">
            <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
                <div class="flex justify-between items-center py-4">
                    <h1 class="text-2xl font-bold text-gray-900">微积分可视化学习平台</h1>
                    <div class="flex items-center space-x-4">
                        <select id="languageSelect" class="border rounded-md px-3 py-2 text-sm">
                            <option value="zh">中文</option>
                            <option value="en">English</option>
                        </select>
                        <select id="exampleSelect" class="border rounded-md px-3 py-2 text-sm">
                            <option value="custom">自定义函数</option>
                            <option value="sinx/x">sin(x)/x 极限</option>
                            <option value="x^2">x² 导数</option>
                            <option value="sinx">sin(x) 泰勒展开</option>
                            <option value="1/x">1/x 积分</option>
                        </select>
                    </div>
                </div>
            </div>
        </header>

        <!-- 主要内容区域 -->
        <main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
            <div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
                <!-- 左侧控制面板 -->
                <div class="lg:col-span-1">
                    <div class="bg-white rounded-lg shadow p-6">
                        <h3 class="text-lg font-semibold mb-4">函数输入</h3>
                        <div class="space-y-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-2">
                                    函数表达式
                                </label>
                                <input type="text" id="functionInput" 
                                    class="w-full border rounded-md px-3 py-2"
                                    placeholder="例如: sin(x)/x">
                            </div>
                            <div class="grid grid-cols-2 gap-2">
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">
                                        起始值
                                    </label>
                                    <input type="number" id="startX" value="-10" 
                                        class="w-full border rounded-md px-3 py-2">
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">
                                        结束值
                                    </label>
                                    <input type="number" id="endX" value="10" 
                                        class="w-full border rounded-md px-3 py-2">
                                </div>
                            </div>
                            <button id="plotBtn" 
                                class="w-full bg-blue-600 text-white rounded-md py-2 hover:bg-blue-700">
                                绘制函数
                            </button>
                        </div>

                        <div class="mt-6">
                            <h4 class="text-md font-semibold mb-3">微积分操作</h4>
                            <div class="space-y-2">
                                <button id="limitBtn" 
                                    class="w-full bg-green-600 text-white rounded-md py-2 hover:bg-green-700">
                                    计算极限
                                </button>
                                <button id="derivativeBtn" 
                                    class="w-full bg-purple-600 text-white rounded-md py-2 hover:bg-purple-700">
                                    计算导数
                                </button>
                                <button id="integralBtn" 
                                    class="w-full bg-orange-600 text-white rounded-md py-2 hover:bg-orange-700">
                                    计算积分
                                </button>
                                <button id="taylorBtn" 
                                    class="w-full bg-red-600 text-white rounded-md py-2 hover:bg-red-700">
                                    泰勒展开
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 右侧可视化区域 -->
                <div class="lg:col-span-3">
                    <div class="bg-white rounded-lg shadow">
                        <div class="p-6">
                            <canvas id="functionChart" width="800" height="400"></canvas>
                        </div>
                    </div>
                    
                    <!-- 结果展示区域 -->
                    <div class="mt-6 bg-white rounded-lg shadow p-6">
                        <h3 class="text-lg font-semibold mb-4">计算结果</h3>
                        <div id="resultDisplay" class="text-gray-700">
                            <p class="text-sm text-gray-500">请输入函数并选择操作查看结果</p>
                        </div>
                    </div>

                    <!-- 公式说明区域 -->
                    <div class="mt-6 bg-white rounded-lg shadow p-6">
                        <h3 class="text-lg font-semibold mb-4">公式说明</h3>
                        <div id="formulaDisplay" class="text-gray-700">
                            <p class="text-sm text-gray-500">选择操作后将显示相关公式</p>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <!-- 引入Chart.js -->
    <script src="https://cdn.bootcdn.net/ajax/libs/Chart.js/4.4.0/chart.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/mathjs/11.11.0/math.min.js"></script>
    
    <!-- 自定义脚本 -->
    <script src="js/calculus.js"></script>
    <script src="js/app.js"></script>
</body>
</html>
